package proxy.demo4;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class UserServiceProxyHandler implements InvocationHandler {
    // 被代理的真实对象
    private final Object target;

    public UserServiceProxyHandler(Object target) {
        this.target = target;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("Before method: " + method.getName());  // 前置增强逻辑‌:ml-citation{ref="5,6" data="citationList"}
        Object result = method.invoke(target, args);  // 调用原始方法‌:ml-citation{ref="1,5" data="citationList"}
        System.out.println("After method: " + method.getName());   // 后置增强逻辑‌:ml-citation{ref="5,6" data="citationList"}
        return result;
    }
}
